-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add decode kvsdb tool #2059
add decode kvsdb tool #2059
Conversation
[CHATOPS:HELP] ChatOps commands.
|
Deploying with Cloudflare Pages
|
hack/tools/kvsdb/main.go
Outdated
kvsdb.Set(k, id, 0) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be better to add header.
hack/tools/kvsdb/main.go
Outdated
f, _ = file.Open( | ||
file.Join(*path, *kvsFileName), | ||
os.O_RDONLY|os.O_SYNC, | ||
fs.ModePerm, | ||
) | ||
_ = gob.NewDecoder(f).Decode(&m) | ||
|
||
// timestamp | ||
mt := make(map[string]int64) | ||
gob.Register(map[string]int64{}) | ||
var ft *os.File | ||
defer ft.Close() | ||
ft, _ = file.Open( | ||
file.Join(*path, *kvsTimestampFileName), | ||
os.O_RDONLY|os.O_SYNC, | ||
fs.ModePerm, | ||
) | ||
_ = gob.NewDecoder(ft).Decode(&mt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should stop this program like below when it returns errors because there can be the case such as no permission.
And I think you should consider logging levels.
This suggestion is just idea.
f, _ = file.Open( | |
file.Join(*path, *kvsFileName), | |
os.O_RDONLY|os.O_SYNC, | |
fs.ModePerm, | |
) | |
_ = gob.NewDecoder(f).Decode(&m) | |
// timestamp | |
mt := make(map[string]int64) | |
gob.Register(map[string]int64{}) | |
var ft *os.File | |
defer ft.Close() | |
ft, _ = file.Open( | |
file.Join(*path, *kvsTimestampFileName), | |
os.O_RDONLY|os.O_SYNC, | |
fs.ModePerm, | |
) | |
_ = gob.NewDecoder(ft).Decode(&mt) | |
var err error | |
f, err = file.Open( | |
file.Join(*path, *kvsFileName), | |
os.O_RDONLY|os.O_SYNC, | |
fs.ModePerm, | |
) | |
if err != nil { | |
log.Fatal(err) | |
} | |
if err = gob.NewDecoder(f).Decode(&m); err != nil { | |
log.Fatal(err) | |
} | |
// timestamp | |
mt := make(map[string]int64) | |
gob.Register(map[string]int64{}) | |
var ft *os.File | |
defer ft.Close() | |
ft, err = file.Open( | |
file.Join(*path, *kvsTimestampFileName), | |
os.O_RDONLY|os.O_SYNC, | |
fs.ModePerm, | |
) | |
if err != nil { | |
log.Fatal(err) | |
} | |
if err = gob.NewDecoder(ft).Decode(&mt); err != nil { | |
log.Fatal(err) | |
} |
hack/tools/kvsdb/main.go
Outdated
s = append(s, []string{k, strconv.FormatUint(uint64(id), 10), "0"}) | ||
} | ||
if len(s)*int(unsafe.Sizeof("")) > 4e+6 { | ||
w.WriteAll(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
w.WriteAll(s) | |
if err = w.WriteAll(s); err != nil { | |
log.Warn(err) | |
} |
hack/tools/kvsdb/main.go
Outdated
s = nil | ||
} | ||
} | ||
w.WriteAll(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
w.WriteAll(s) | |
if err = w.WriteAll(s); err != nil { | |
log.Fatal(err) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description:
add decode kvsdb tool.
run example:
Related Issue:
Versions:
Checklist:
Special notes for your reviewer: